﻿#region Copyright (c) 2006-2012 nHydrate.org, All Rights Reserved
// --------------------------------------------------------------------- *
//                           NHYDRATE.ORG                                *
//              Copyright (c) 2006-2012 All Rights reserved              *
//                                                                       *
//                                                                       *
// This file and its contents are protected by United States and         *
// International copyright laws.  Unauthorized reproduction and/or       *
// distribution of all or any portion of the code contained herein       *
// is strictly prohibited and will result in severe civil and criminal   *
// penalties.  Any violations of this copyright will be prosecuted       *
// to the fullest extent possible under law.                             *
//                                                                       *
// THE SOURCE CODE CONTAINED HEREIN AND IN RELATED FILES IS PROVIDED     *
// TO THE REGISTERED DEVELOPER FOR THE PURPOSES OF EDUCATION AND         *
// TROUBLESHOOTING. UNDER NO CIRCUMSTANCES MAY ANY PORTION OF THE SOURCE *
// CODE BE DISTRIBUTED, DISCLOSED OR OTHERWISE MADE AVAILABLE TO ANY     *
// THIRD PARTY WITHOUT THE EXPRESS WRITTEN CONSENT OF THE NHYDRATE GROUP *
//                                                                       *
// UNDER NO CIRCUMSTANCES MAY THE SOURCE CODE BE USED IN WHOLE OR IN     *
// PART, AS THE BASIS FOR CREATING A PRODUCT THAT PROVIDES THE SAME, OR  *
// SUBSTANTIALLY THE SAME, FUNCTIONALITY AS THIS PRODUCT                 *
//                                                                       *
// THE REGISTERED DEVELOPER ACKNOWLEDGES THAT THIS SOURCE CODE           *
// CONTAINS VALUABLE AND PROPRIETARY TRADE SECRETS OF NHYDRATE,          *
// THE REGISTERED DEVELOPER AGREES TO EXPEND EVERY EFFORT TO             *
// INSURE ITS CONFIDENTIALITY.                                           *
//                                                                       *
// THE END USER LICENSE AGREEMENT (EULA) ACCOMPANYING THE PRODUCT        *
// PERMITS THE REGISTERED DEVELOPER TO REDISTRIBUTE THE PRODUCT IN       *
// EXECUTABLE FORM ONLY IN SUPPORT OF APPLICATIONS WRITTEN USING         *
// THE PRODUCT.  IT DOES NOT PROVIDE ANY RIGHTS REGARDING THE            *
// SOURCE CODE CONTAINED HEREIN.                                         *
//                                                                       *
// THIS COPYRIGHT NOTICE MAY NOT BE REMOVED FROM THIS FILE.              *
// --------------------------------------------------------------------- *
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace nHydrate.Generator.Common.Util
{
	public static class Extensions
	{
		public static List<EnvDTE.Project> GetProjects(this EnvDTE80.Solution2 solution)
		{
			var projects = new List<EnvDTE.Project>();
			for (var ii = 1; ii <= solution.Count; ii++)
			{
				var project = solution.Item(ii);
				if (project.Kind == "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}")
					projects.Add(project);
			}
			return projects;
		}

		public static List<EnvDTE.Project> GetFolders(this EnvDTE80.Solution2 solution)
		{
			var folders = new List<EnvDTE.Project>();
			for (var ii = 1; ii <= solution.Count; ii++)
			{
				var project = solution.Item(ii);
				if ((project.Kind == "{66A26720-8FB5-11D2-AA7E-00C04F688DDE}") ||
					(project.Kind == "{66A26722-8FB5-11D2-AA7E-00C04F688DDE}"))
				{
					folders.Add(project);
				}
			}
			return folders;
		}

		public static List<EnvDTE.Project> GetFolders(this EnvDTE.Project project)
		{
			var folders = new List<EnvDTE.Project>();
			for (var ii = 1; ii <= project.ProjectItems.Count; ii++)
			{
				var child = project.ProjectItems.Item(ii);
				if ((child.Kind == "{66A26720-8FB5-11D2-AA7E-00C04F688DDE}") ||
					(child.Kind == "{66A26722-8FB5-11D2-AA7E-00C04F688DDE}"))
				{
					folders.Add(child as EnvDTE.Project);
				}
			}
			return folders;
		}

		//public static List<EnvDTE.Project> GetFolders(this EnvDTE80.SolutionFolder project)
		//{
		//  var folders = new List<EnvDTE.Project>();
		//  for (int ii = 1; ii <= project.ot.ProjectItems.Count; ii++)
		//  {
		//    var child = project.ProjectItems.Item(ii);
		//    if (child.Kind == "{66A26720-8FB5-11D2-AA7E-00C04F688DDE}")
		//      folders.Add(project);
		//  }
		//  return folders;
		//}

	}
}
